import java.util.Random;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 晓星航
 * Date: 2022-10-09
 * Time: 12:38
 */
//    public static int sumAdd(int n){
//        int sum = 0;
//        for (int i = 1; i <= n; i++) {
//            sum += i;
//        }
//        return sum;
//    }
//public static int fac(int n){
//    int ret = 1;
//    int sum = 0;
//    for (int i = 1; i <= n; i++) {
//        ret *= i;
//        sum += ret;
//    }
//    return sum;
//}
//    public static void main(String[] args) {
//        Scanner scanner = new Scanner(System.in);
//        int n = scanner.nextInt();
//        int ret = fac(n);
//        System.out.println(ret);
//    }
//    public static void main7(String[] args) {
//        int n = 10;
//        int ret = sumAdd(n);
//        System.out.println(ret);
//    }

public class TestDemo1 {
    public static void main(String[] args) {
        Random random = new Random();
        int rand = random.nextInt(10000);
        Scanner scanner = new Scanner(System.in);
        while(true){
            System.out.println("请输入一个数字：");
            int n = scanner.nextInt();
            if (n > rand){
                System.out.println("猜大了");
            } else if (n < rand) {
                System.out.println("猜小了");
            } else {
                System.out.println("猜对了");
                break;
            }
        }
    }
    public static void login(){
        Scanner scanner = new Scanner(System.in);
        int count = 3;
        while (count != 0){
            System.out.println("请输入你的密码：");
            String password = scanner.nextLine();
            if(password.equals("123456")){
                System.out.println("登录成功了！");
                break;
            } else {
                count--;
                System.out.println("你输错密码了，你还有"+count+"次机会！");
            }
        }
    }
    public static void main11(String[] args) {
        login();
    }
    public static int add(int x, int y) {
        return x + y;
    }
    public static double add(double x, double y) {
        return x + y;
    }
    public static double add(double x, double y, double z) {
        return x + y + z;
    }

    public static void main10(String[] args) {
        int a = 10;
        int b = 20;
        int ret = add(a, b);
        System.out.println("ret = " + ret);
        double a2 = 10.5;
        double b2 = 20.5;
        double ret2 = add(a2, b2);
        System.out.println("ret2 = " + ret2);
        double a3 = 10.5;
        double b3 = 10.5;
        double c3 = 20.5;
        double ret3 = add(a3, b3, c3);
        System.out.println("ret3 = " + ret3);
    }
    public static void main9(String[] args) {
        int a = 10;
        int b = 20;
        int ret = add(a, b);
        System.out.println("ret = " + ret);
        double a2 = 10.5;
        double b2 = 20.5;
        double ret2 = add(a2, b2);
        System.out.println("ret2 = " + ret2);
    }
    public static void swap(int[] arr) {
        int tmp = arr[0];
        arr[0] = arr[1];
        arr[1] = tmp;
    }
    public static void main8(String[] args) {
        int[] arr = {10, 20};
        swap(arr);
        System.out.println("a = " + arr[0] + " b = " + arr[1]);
    }
    public static void main7(String[] args) {
        int a = 10;
        int b = 20;
        System.out.println("交换前:"+a+" "+b);
        System.out.println("交换后:"+a+" "+b);
    }
    public static void main6(String[] args) {
        int a = 10;
        int b = 20;

        // 方法的调用
        int ret = add(a, b);
        System.out.println("ret = " + ret);
    }
    // 方法的定义
    public static void main5(String[] args) {
        int count = 0;
        for (int i = 1; i <= 100; i++) {
            if (i % 10 == 9){
                count++;
            }
            if (i / 10 == 9) {
                count++;
            }
        }
        System.out.println(count);
    }
    public static void main4(String[] args) {
        double sum = 0.0;
        int flg = 1;
        for (double i = 1; i <= 100; i++) {
            sum = sum + 1/i * flg;
            flg = -flg;
        }
        System.out.println(sum);
    }
    public static void main3(String[] args) {
        int a = 18;
        int b = 24;
        int c = a % b;
        int d = a * b;
        while(c != 0){
            a = b;//被除数等于除数
            b = c;//除数等于余数
            c = a % b;//余数等于被除数除除数
        }
        System.out.println("最大公约数是" + b);
        System.out.println("最小公倍数是" + d/b);
    }
    public static void main2(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= i; j++) {
                System.out.print(j + "*" + i + "=" + i*j + " ");
            }
            System.out.println();
        }
    }
    public static void main1(String[] args) {
        Random random = new Random();
        int rand = random.nextInt(100);
        Scanner scanner = new Scanner(System.in);
        while(true){
            System.out.println("请输入一个要猜的数字：->");
            int n = scanner.nextInt();
            if (n > rand) {
                System.out.println("猜大了");
            } else if (n == rand) {
                System.out.println("猜对了");
                break;
            } else {
                System.out.println("猜小了");
            }
        }
    }
}
